﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>授权待办列表</title>
    <script language="JavaScript" src="./Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="./Scripts/QueryString.js" type="text/javascript"></script>
    <script src="./Scripts/config.js" type="text/javascript"></script>
    <script src="./Comm/Gener.js" type="text/javascript"></script>
    <base target="_self" />
    <link href="../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }
        function LogAs(fk_emp, empName) {
            if (window.confirm('您确定要以[' + empName + ']授权方式登陆处理工作吗？') == false)
                return;


            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddPara("No", fk_emp);
            var msg = handler.DoMethodReturnString("LoginAs");

            if (msg.indexOf('err') == 0) {
                alert('授权登录失败!');
            }
            else {
                parent.location.reload();
                //top.location.href = '../WF/App/Classic/index.jsp';
                top.location.href = './Todolist.htm';
                //window.open('Todolist.htm');
            }

        }
        //页面启动函数.
        $(function () {

            // return;

            // $("#Msg").html("&nbsp;<h1>重构过程中.<a href='Todolist.htm'>返回我的待办..</a> <a href='AutoTodolist.aspx'>使用旧版本</a></h1>");
            //   return;

            //   $("#Msg").html("<img src=./Img/loading.gif />&nbsp;正在加载,请稍后......");


            InitPage();

            $("#Msg").html("");
        });

        //初始化数据.
        function InitPage() {

            var fk_node = GetQueryString("FK_Node");

            //初始化表格.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddPara("FK_Node", fk_node);
            var data = handler.DoMethodReturnString("TodolistOfAuth_Init");

            data = JSON.parse(data);
            var timeKey = "ss";
            var newRow = ""; //tab标签
            var conMenu = ""; //待办列表
            for (var i = 0; i < data.length; i++) {
                if (i == 0) {
                    newRow += "<li id='menu" + (i + 1) + "' onclick=\"setTab('menu'," + (i + 1) + "," + data.length + ")\" class='hover'>" + data[i].NAME + "的待办</li>";
                    conMenu += "<div id='con_menu_" + (i + 1) + "' class='hover'>";
                }
                else {
                    newRow += "<li id='menu" + (i + 1) + "' onclick=\"setTab('menu'," + (i + 1) + "," + data.length + ")\">" + data[i].NAME + "的待办</li>";
                    conMenu += "<div id='con_menu_" + (i + 1) + "'  style='display:none'>";
                }

                //生成对应授权人的待办列表的top
                conMenu += "<table id='Table" + (i + 1) + "' width='100%'  cellspacing='0' cellpadding='0' align='left'>";
                conMenu += "<tr class='centerTitle'>";
                conMenu += "<th>序</th><th>优先级</th><th>标题</th><th>流程</th><th>节点</th><th>发起人</th>";
                conMenu += "<th>发起日期</th><th>接受日期</th><th>应完成日期</th><th>状态</th><th>类型</th><th>备注</th>";
                conMenu += "</tr>";

                //输出待办详细信息
                var handler = new HttpHandler("BP.WF.HttpHandler.WF");
                handler.AddPara("FK_Node", fk_node);
                handler.AddPara("No", data[i].NO);
                var msg = handler.DoMethodReturnString("Todolist_Author");

                msg = JSON.parse(msg);

                for (var j = 0; j < msg.length; j++) {
                    var title = msg[j].TITLE;
                    var isRead = msg[j].ISREAD;
                    var flowNo = msg[j].FK_FLOW;
                    var flowName = msg[j].FLOWNAME;
                    var nodeName = msg[j].NODENAME;
                    var starterName = msg[j].STARTERNAME;
                    var pri = msg[j].PRI;
                    var nodeID = msg[j].FK_NODE;
                    var fid = msg[j].FID;
                    var workID = msg[j].WORKID;
                    var paras = msg[j].PARAS;
                    var cdt = getNowFormatDate();

                    conMenu += "<tr > <td>" + (j + 1) + "</td>"; //序号
                    conMenu += "<td><img class=Icon src='../WF/Img/PRI/" + pri + ".png' class=Icon /></td>"; //优先级
                    var url = "";
                    if (isRead == 0) {
                        url = "<a href=\"javascript:LogAs('" + data[i].NO + "','" + data[i].NAME + "');\" ><img class=Icon align='middle'  src='../WF/Img/Mail_UnRead.png' />" + title + "</a>";
                    } else {
                        url = "<a href=\"javascript:LogAs('" + data[i].NO + "','" + data[i].NAME + "');\" ><img class=Icon align='middle'  src='../WF/Img/Mail_Read.png' />" + title + "</a>";
                    }

                    conMenu += "<td>" + url + "</td>"; //标题
                    conMenu += "<td>" + flowName + "</td>"; //流程类别
                    conMenu += "<td>" + nodeName + "</td>"; //节点名称
                    conMenu += "<td>" + starterName + "</td>"; //发起人


                    conMenu += "<td>" + msg[j].RDT + "</td>"; //发起时间
                    conMenu += "<td>" + msg[j].ADT + "</td>"; //接受时间
                    conMenu += "<td>" + msg[j].SDT + "</td>"; //应完成时间
                    //判断流程是否逾期
                    if (cdt > msg[j].SDT && msg[j].WFSTATE == 2) {
                        conMenu += "<td><img src='../WF/Img/TolistSta/2.png' class='Icon'/><font color=red>逾期</font></td>";
                    }
                    else {
                        conMenu += "<td><img src='../WF/Img/TolistSta/0.png' class='Icon'/><font color=green>正常</font></td>";
                    }
                    //待办的状态.
                    switch (msg[j].WFSTATE) {
                        case 1:
                            conMenu += "<td>草稿</td>";
                            break;
                        case 2:
                            conMenu += "<td>待办</td>";
                            break;
                        case 3: //已完成.
                            break;
                        case 4:
                            conMenu += "<td>挂起</td>";
                            break;
                        case 5:
                            conMenu += "<td>退回</td>";
                            break;
                        case 6:
                            conMenu += "<td>转发</td>";
                            break;
                        case 7:
                            conMenu += "<td>删除</td>";
                            break;
                        case 8:
                            conMenu += "<td>加签</td>";
                            break;
                        case 11:
                            conMenu += "<td>加签回复</td>";
                            break;
                        default:
                            conMenu += "<td>其他</td>";
                            break;
                    }
                    //备注
                    conMenu += "<td width='100'><div style='width:100px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;' title='" + msg[j].FLOWNOTE + "'>" + msg[j].FLOWNOTE + "</div></td>";
                    conMenu += "</tr>";
                }

                conMenu += "</table>";
                conMenu += "</div>";
            }
            //显示tab标签
            $('#Tab_Menu').html([
                        newRow
                    ].join(''));
            //显示待办列表
            $('#Div_Content').html([
                        conMenu
                    ].join(''));

        }
        //获取当前时间
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            //当前时间=年份-月份-日 小时：分钟
            var cdt = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes();

            return cdt;
        }
    </script>
    <style type="text/css">
        body
        {
            font: "宋体";
            font-size: 12px;
        }
        a:link, a:visited
        {
            font-size: 12px;
            color: #666;
            text-decoration: none;
        }
        a:hover
        {
            color: #ff0000;
            text-decoration: underline;
        }
        #Tab
        {
            margin: 0 auto;
            width: 100%;
            border: 1px solid #BCE2F3;
        }
        .Menubox
        {
            height: 28px;
            border-bottom: 1px solid #64B8E4;
            background: #E4F2FB;
        }
        .Menubox ul
        {
            list-style: none;
            margin: 7px 5px;
            padding: 0;
            position: absolute;
        }
        .Menubox ul li
        {
            float: left;
            background: #64B8E4;
            line-height: 20px;
            display: block;
            cursor: pointer;
            width: 135px;
            text-align: center;
            color: #fff;
            font-weight: bold;
            border-top: 1px solid #64B8E4;
            border-left: 1px solid #64B8E4;
            border-right: 1px solid #64B8E4;
        }
        .Menubox ul li.hover
        {
            background: #fff;
            border-bottom: 1px solid #fff;
            color: #147AB8;
        }
        .Contentbox
        {
            clear: both;
            margin-top: 0px;
            border-top: none;
            height: 181px;
            padding-top: 8px;
            height: 100%;
        }
        .Contentbox ul
        {
            list-style: none;
            margin: 7px;
            padding: 0;
        }
        .Contentbox ul li
        {
            line-height: 24px;
            border-bottom: 1px dotted #ccc;
        }
    </style>
    <script type="text/javascript">
        function setTab(name, cursel, n) {
            for (i = 1; i <= n; i++) {
                var menu = document.getElementById(name + i);
                var con = document.getElementById("con_" + name + "_" + i);
                menu.className = i == cursel ? "hover" : "";
                con.style.display = i == cursel ? "block" : "none";
            }
        } 
    </script>
</head>
<body>
    <div id="Msg">
    </div>
    <div id="Tab">
        <div class="Menubox">
            <ul id="Tab_Menu">
            </ul>
        </div>
        <div id="Div_Content" class="Contentbox">
        </div>
    </div>
</body>
</html>
